<?php
/**
 * Created by PhpStorm.
 * User: weijer
 * Date: 2018/10/26
 * Time: 21:17
 */

namespace common\validate;

use think\Validate;

class Options extends BaseValidate
{
    //验证规则
    protected $rule = [];


    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Create 验证场景定义
    public function sceneCreate()
    {
        return $this->append('data.options_name', 'require|max:128')
            ->append('data.type', 'require|max:128')
            ->append('data.config', 'require|array');
    }

    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this
//            ->append('data.id', 'require')
            ->append('data.options_name', 'max:128')
            ->append('data.type', 'max:128')
            ->append('data.config', 'array');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require|array');
    }
}
